<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
	$escort_id = intval($this->input->get('escort_id',0));
	$ESCORT = $this->escort_entity->init('id',$escort_id);
	$ESCORT->addPointEscortEditProfile();
	
	$numberVisitted = $this->escort_visitted_entity->countNumberVisittedOfEscortInMonth($ESCORT->getId(),time());
	$numberVisitted = $numberVisitted ? $numberVisitted:0;
	$numberMessage = $this->visitor_contact_entity->countAllMessagesEscortReceipt($ESCORT->getId());
	$PAYMENT_LOG = $this->payment_log_entity->getNetAmount($ESCORT->getId());
	$LATEST_PAYMENT = $this->payment_history->getLatestPaymentHistory($ESCORT->getId());
	
	$countUnread = $this->escort_message_thread_entity->countAllUnreadMessagesOfUser($USER->getId(),USER_TYPE_AGENT);	
?>

<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php echo language_translate('dashboard_lable_visits');?></span></div>
	<div class="dashboard-info-right">
		<span class="gray"><?php echo str_replace('%1',$numberVisitted, language_translate('dashboard_content_visits'));?></span>
	</div>
	<div class="clear"></div>
</div>
<hr class="background-separate"/>
<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php echo language_translate('dashboard_lable_position');?></span></div>
	<div class="dashboard-info-right">
		<span class="gray"><?php echo str_replace('%1',$ESCORT->getNumberFirstStanding(), language_translate('dashboard_content_position'));?></span>
	</div>
	<div class="clear"></div>
</div>
<hr class="background-separate"/>
<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php echo language_translate('dashboard_lable_contact_data');?></span></div>
	<div class="dashboard-info-right">
		<span class="gray"><?php echo str_replace( array('%1','%2'), array(intval($ESCORT->getTimesPhoneDisplayed()), $numberMessage) , language_translate('dashboard_content_contact_data') );?></span>
	</div>
	<div class="clear"></div>
</div>
<hr class="background-separate"/>
<!-- 
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('dashboard_lable_current_services');?></span></div>
		<div class="dashboard-info-right">
			<?php //if($PAYMENT_LOG): ?> 
				<span class="gray"><?php //echo str_replace('%1',$PAYMENT_LOG,language_translate('dashboard_content_current_services'));?></span>
				<span class="black"><a href="<?php //echo site_url("agent/account/services");?>"><?php //echo language_translate('dashboard_content_current_services_link');?></a></span>
			<?php // endif; ?>
		</div>
		<div class="clear"></div>
	</div>
	<hr class="background-separate"/>
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('dashboard_lable_last_payment');?></span></div>
		<div class="dashboard-info-right">
			<?php  //if($LATEST_PAYMENT): ?>
				<span class="gray"><?php //echo $LATEST_PAYMENT->getNetAmount();?> &euro; <?php //echo language_translate('dashboard_lable_credit_card');?></span>
				<span class="black"><a href="<?php //echo site_url("agent/account/payment_history");?>"><?php //echo language_translate('dashboard_lable_history');?></a></span>
			<?php //endif;?>
		</div>
		<div class="clear"></div>
	</div>
 -->
 
<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php echo language_translate('dashboard_lable_unread_message');?></span></div>
	<div class="dashboard-info-right">
		<span class="gray"><?php echo str_replace('%1',$countUnread,language_translate('dashboard_content_unread_message'));?></span>
	</div>
	<div class="clear"></div>
</div>
<!--
<hr class="background-separate"/>
<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php //echo language_translate('dashboard_lable_offer');?></span></div>
	<div class="dashboard-info-right">
		<span class="gray"><a href="<?php //echo site_url("agent/account/payment_nextmonth");?>"><?php //echo language_translate('dashboard_lable_offer_link');?></a></span>
	</div>
	<div class="clear"></div>
</div>
-->
<hr class="background-separate"/>
<div class="dashboard-info-wrapper">
	<div class="dashboard-info-left"><span><?php echo language_translate('dashboard_lable_popular_image');?></span></div>
	<div class="dashboard-info-right">
		<?php $OBJ = $this->media_entity->getObjectOfMostPopularImage($ESCORT->getId());?>
		<?php if($OBJ AND $OBJ->getClickedNo() > 0):?>
			<!-- 
			<span class="gray">
				<a href="javascript:void(0);" onclick="return openMostPopularImage(<?php //echo $OBJ->getId();?>);"><?php //if($OBJ) echo $OBJ->getName();?></a>
			</span>
			 -->
			<?php if($OBJ->getType() =='image'):?>
				<?php echo thumb($OBJ->getTargetFileImageTopPublic('big'),THUMB_WW,THUMB_HH);?>
			<?php else:?>
				<?php echo playvideo($OBJ->getTargetFile('video'),$OBJ->getTargetFile('avatar'),THUMB_WW,THUMB_HH);?>
			<?php endif; ?>
		<?php endif;?>
	</div>
	<div class="clear"></div>
</div>
<hr class="background-separate"/>

<div class="dashboard-info-wrapper">
	<div id="googlechart"></div>	
	<div class="clear"></div>
</div>

<?php 
	$arrayNumberVisittedByMonth = $this->escort_visitted_entity->arrayVisittedOfEscortAllTime($ESCORT->getId());
	$arrayJS =  array();
	if($arrayNumberVisittedByMonth){
		foreach($arrayNumberVisittedByMonth as $key => $val){
			list($from , $to) = explode('_',$key);
			$arrayJS[] = array( date('m/Y',$from), intval($val)); 
		}
	}
	$json = json_encode($arrayJS);
?>

<script type="text/javascript">
	google.load("visualization", "1", {packages:["corechart"]});
	function drawVisualization() {
		  var data = new google.visualization.DataTable();
		  data.addColumn('string', '<?php echo language_translate('dashboard_lable_month_chart');?>');
		  data.addColumn('number', '<?php echo language_translate('dashboard_lable_visitted_time');?>');
		
		  data.addRows(<?php echo $json;?>);
		  var ac = new google.visualization.ColumnChart(document.getElementById('googlechart'));
		  ac.draw(data, {
			title : '<?php echo language_translate('dashboard_lable_chart_title');?>',
			isStacked: false,
			width: 600,
			height: 400,
			vAxis: {title: "<?php echo language_translate('dashboard_lable_visitted_time');?>" },
			hAxis: {title: "<?php echo language_translate('dashboard_lable_month_chart');?>", viewWindow:{max:10},slantedText:true,slantedTextAngle:60},
			lineWidth:0,
			
		  });
	}
	
	$(document).ready(function(){drawVisualization()});
	
	function openMostPopularImage(media_id){
		$('#greyDiv').removeClass('hidden');
		$.get(BASE_URI+'agent/async/getDialog_openMostPopularImage',{media_id:media_id},function(res){
			$('#hiddenElement').html(res);
			$('#hiddenElement').dialog(
				{
					 width: 650,
					 height:350 ,
					 draggable: false,
					 beforeClose: function(event, ui) { 
						$('#greyDiv').addClass('hidden');
					 },
					 close: function(event, ui) { 
					},
					 title: '<?php echo language_translate('dashboard_lable_popular_image');?>' 
				}
			);
			$('.ui-dialog').center();
		});
	}
</script>


